import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter)
const Home=()=>import('@pages/Home')
const Login=()=>import('@pages/Login')
const Register=()=>import('@pages/Register')
const Detail=()=>import('@pages/Detail')
const Search=()=>import('@pages/Search')
//重写路由器的push方法
const lastPush=VueRouter.prototype.push
VueRouter.prototype.push=function(
    loaction,
    onComplete=()=>{},
    onAbort=()=>{}
){
    return lastPush.call(this,loaction,onComplete,onAbort)
}
export default new VueRouter({
    mode:'history',
    routes:[
        {path:'/home',component:Home,name:'home'},
        {path:'/login',component:Login,name:'login',meta:{isFooterHide:true}},
        {path:'/register',component:Register,name:'register',meta:{isFooterHide:true}},
        {path:'/detail/:skuId',component:Detail,name:'detail'},
        {path:'/search/:keyword?',component:Search,name:'search'},
        {path:"/",redirect:'/home'}
    ]
})